cmake_minimum_required(VERSION 2.8)

get_filename_component(MODULE_BASE "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_MODULE_PATH "${MODULE_BASE}/;${CMAKE_MODULE_PATH}")
include(GccSearchPaths)

set(INSTALL_IN_SOURCE_TREE TRUE CACHE BOOL "Output final targets to the source tree")

# for default builds, output goes into (sub-directories of) the source tree
# output executables, .so files and .a files to the bin/ and lib/ directories
if (INSTALL_IN_SOURCE_TREE)
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib")
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib")
endif()

set(CMAKE_DEBUG_POSTFIX "-dbg")
function(ithaca_executable name)
   add_executable(${ARGV})
   set_target_properties(${name} PROPERTIES OUTPUT_NAME_DEBUG "${name}-dbg")
endfunction()
